package com.chain.qs.modules.biz.dp.handler;

import com.chain.qs.modules.biz.entity.EquipmentItemRecordCAGospell1kWSpDev;
import com.chain.qs.modules.biz.service.EquipmentItemRecordCAGospell1kWSpDevService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.Map;

/**
 * CAGospell1kWSpDev
 */
@Component("CAGospell1kWSpDev")
public class CAGospell1kWSpDev extends AbstractDPHandler {
    @Resource
    private EquipmentItemRecordCAGospell1kWSpDevService equipmentItemRecordCAGospell1kWSpDevService;

    public void saveData(Map<String, Object> params) {
        EquipmentItemRecordCAGospell1kWSpDev entity = new EquipmentItemRecordCAGospell1kWSpDev();
        entity.setOfficeCode(officeCode);
        entity.setSgroupId(sgroupId);
        entity.setGitemId(deviceId);
        entity.setPower(params.get("power") != null ? params.get("power").toString() : "");
        entity.setSwr(params.get("swr") != null ? params.get("swr").toString() : "");
        entity.setTemperature(params.get("temp") != null ? params.get("temp").toString() : "");
        entity.setM1OutputPower(params.get("m_1_ou_pw") != null ? params.get("m_1_ou_pw").toString() : "");
        entity.setM1Swr(params.get("m_1_swr") != null ? params.get("m_1_swr").toString() : "");
        entity.setM1Temperature(params.get("m_1_temp") != null ? params.get("m_1_temp").toString() : "");
        entity.setM1Current(params.get("m_1_ct") != null ? params.get("m_1_ct").toString() : "");
        entity.setM1Voltage(params.get("m_1_vol") != null ? params.get("m_1_vol").toString() : "");
        entity.setM2OutputPower(params.get("m_2_ou_pw") != null ? params.get("m_2_ou_pw").toString() : "");
        entity.setM2Swr(params.get("m_2_swr") != null ? params.get("m_2_swr").toString() : "");
        entity.setM2Temperature(params.get("m_2_temp") != null ? params.get("m_2_temp").toString() : "");
        entity.setM2Current(params.get("m_2_ct") != null ? params.get("m_2_ct").toString() : "");
        entity.setM2Voltage(params.get("m_2_vol") != null ? params.get("m_2_vol").toString() : "");
        entity.setM3OutputPower(params.get("m_3_ou_pw") != null ? params.get("m_3_ou_pw").toString() : "");
        entity.setM3Swr(params.get("m_3_swr") != null ? params.get("m_3_swr").toString() : "");
        entity.setM3Temperature(params.get("m_3_temp") != null ? params.get("m_3_temp").toString() : "");
        entity.setM3Current(params.get("m_3_ct") != null ? params.get("m_3_ct").toString() : "");
        entity.setM3Voltage(params.get("m_3_vol") != null ? params.get("m_3_vol").toString() : "");
        entity.setTimeStamp(new Timestamp(System.currentTimeMillis()));
        equipmentItemRecordCAGospell1kWSpDevService.save(entity);
    }
}
